package com.example.demo9;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "helloServlet", value = "/employee.do")
public class HelloServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        request.setCharacterEncoding("gb2312");
        response.setContentType("text/html;charset=gb2312");

        EmployeeBean employee = new EmployeeBean();

        employee.setEname(request.getParameter("ename"));
        employee.setEcompany(request.getParameter("ecompany"));
        employee.setEno(request.getParameter("eno"));

        request.setAttribute("employee",employee);

        RequestDispatcher dispatcher = request
                .getRequestDispatcher("/displayEmployee.jsp");
        dispatcher.forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    public void destroy() {
    }
}
